package com.kaia.shoebox.db.dao;

import java.util.Date;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable
public class TodoItem {

	// ------------------------------------------------------------------
	// Database Names
	// ------------------------------------------------------------------

	public static final String ID = "_id";
	public static final String TITLE = "title";
	public static final String DATE_CREATED = "date_created";
	public static final String DUE_DATE = "due_date";
	public static final String DATE_COMPLETED = "date_completed";
	public static final String IMPORTANCE = "importance";
	public static final String NOTES = "notes";

	// ------------------------------------------------------------------
	// Attributes
	// ------------------------------------------------------------------

	@DatabaseField(generatedId = true, columnName = ID)
	private int id;

	@DatabaseField(index = true, columnName = TITLE)
	private String title;

	@DatabaseField(columnName = DATE_CREATED)
	private Date dateCreated;

	@DatabaseField(columnName = DUE_DATE)
	private Date dueDate;

	@DatabaseField(columnName = DATE_COMPLETED)
	private Date dateCompleted;

	@DatabaseField(dataType = DataType.ENUM_STRING, columnName = IMPORTANCE)
	private Importance importance;

	@DatabaseField(canBeNull = true, columnName = NOTES)
	private String notes;

	// ------------------------------------------------------------------
	// Constructors
	// ------------------------------------------------------------------

	public TodoItem() {
	}

	public TodoItem(String title, Date dueDate, String notes,
			Importance importance) {
		setTitle(title);
		setNotes(notes);
		setDueDate(dueDate);
		setImportance(importance);

		this.dateCompleted = null;
		this.dateCreated = new Date();
	}

	public TodoItem(int id, String title, Date dueDate, Importance importance,
			String notes) {
		this.id = id;
		this.dateCreated = new Date();
		this.dateCompleted = null;

		setTitle(title);
		setDueDate(dueDate);
		setImportance(importance);
		setNotes(notes);
	}
	
	// ------------------------------------------------------------------
	// Getters/Setters
	// ------------------------------------------------------------------

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public int getId() {
		return id;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public String getNotes() {
		return notes;
	}

	public Importance getImportance() {
		return importance;
	}

	public void setImportance(Importance importance) {
		this.importance = importance;
	}

	public Date getDateCompleted() {
		return dateCompleted;
	}

	public void setDateCompleted(Date dateCompleted) {
		this.dateCompleted = dateCompleted;
	}

}